﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;

namespace Skynet.WebSite.Mobile.CategoriesMgmView.WAP
{
    public class CategoriesMgmView : IHttpHandler
    {

        public bool IsReusable
        {
            get { return true; }
        }

        public void ProcessRequest(HttpContext context)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("<?xml version='1.0'?>");            
            sb.AppendLine(@"<!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML 1.3//EN' 'http://www.wapforum.org/DTD/wml13.dtd'>'");
            sb.AppendLine("<wml>");

            if (string.IsNullOrWhiteSpace(context.Request.QueryString["Title"]))
            {
                sb.AppendLine("<card id='card1' title='Confirm Category Process'>");
                sb.AppendLine("<p> Category Register Success <br/>");                
                sb.AppendLine("<anchor>");
                sb.AppendLine("<go method='get' href='CategoriesMgmView.wml'>");                
                sb.AppendLine("</go>Accept</anchor></p></card>"); 
            }
            else
            {
                sb.AppendLine("<card id='card1' title='Register Category'>");
                sb.AppendLine("<p> Category Title<br/>");
                sb.AppendLine("<input name='txtTitle'/><br/>");
                sb.AppendLine("Category Description<br/>");
                sb.AppendLine("<input name='txtDescription'/><br/></p>");
                sb.AppendLine("<anchor>");    
                sb.AppendLine("<go method='get' href='CategoriesMgmView.wml'>"); 
                sb.AppendLine("<postfield name='title' value='$(txtTitle)'/>"); 
                sb.AppendLine("<postfield name='description' value='$(txtDescription)'/>");
                sb.AppendLine("</go>Submit Data</anchor></p></card>");       
            }
            sb.AppendLine("</wml>");
            context.Response.ContentType = "text/vnd.wap.wml";
            context.Response.Charset = "";
            context.Response.Write(sb.ToString());
        }
    }
}